home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / cml-098.lha / cml-0.9.8 / src / cml-base-sig.sml < prev    next >
Encoding:
Text File  |  1993-02-19  |  2.6 KB  |  96 lines

  1. (* cml-base-sig.sml
  2.  *)
  3.  
  4. signature CML_BASE =
  5.   sig
  6.  
  7.     val version : {major : int, minor : int, rev : int, date : string}
  8.     val versionName : string
  9.  
  10.     datatype 'a queue_t = Q of {front : 'a list ref, rear : 'a list ref}
  11.  
  12.   (* Per-thread descriptors *)
  13.     datatype thread_id = TID of {  (* thread ids *)
  14.     id       : int,
  15.     done_comm  : bool ref,        (* set this whenever this thread does *)
  16.                     (* some concurrency operation. *)
  17.     death_cond : unit cond_var
  18.       }
  19.   (* condition variables *)
  20.     and 'a cond_var = COND of 'a cond_state ref
  21.     and 'a cond_state
  22.       = COND_unset of (thread_id * bool ref * 'a cont) list
  23.       | COND_set of 'a
  24.  
  25.     val dummyTId : thread_id
  26.  
  27.   (* The thread ready queues:
  28.    * rdyQ1 is the primary queue and rdyQ2 is the secondary queue.
  29.    *)
  30.     val rdyQ1 : (thread_id * unit cont) queue_t
  31.     val rdyQ2 : (thread_id * unit cont) queue_t
  32.  
  33.     val dequeue2 : unit -> (thread_id * unit cont)
  34.     (* remove a thread from the secondary scheduling queue (assuming
  35.      * that the primary queue is empty).
  36.      *)
  37.  
  38.     datatype time = TIME of {sec : int, usec : int}
  39.     sharing type time = System.Timer.time
  40.  
  41.     val currentTime : unit -> time
  42.  
  43.     val timerOff : unit -> unit
  44.     val timerOn : time option -> unit
  45.     val restartTimer : unit -> unit
  46.  
  47.     datatype io_operation_t = IO_RD | IO_WR | IO_EX
  48.  
  49.     val pollFDs : (int list * int list * int list * bool)
  50.       -> (int list * int list *int list)
  51.  
  52.     val insIOWait : {
  53.         fd : int, io_op : io_operation_t, kont : unit cont,
  54.         id : thread_id, err_kont : unit cont, dirty : bool ref
  55.       } -> unit
  56.  
  57.     val insTimeWait : (time * thread_id * unit cont * bool ref) -> unit
  58.  
  59.   (* global flag for implementing atomic operations *)
  60.     datatype atomic_state = NonAtomic | Atomic | SignalPending
  61.     val atomicState : atomic_state ref
  62.  
  63.     val checkWaitingThreads : unit -> unit
  64.  
  65.     val handlePendingSignal : unit -> unit
  66.     (* Complete the exit from an atomic region when there is a
  67.      * pending signal.
  68.      *)
  69.  
  70.     val initCMLBase : unit -> unit
  71.  
  72.     exception InternalError
  73.  
  74.     val reportError : string -> unit
  75.     (* atomically print a message on std_err *)
  76.  
  77.     val error : string -> 'a
  78.     (* report an internal error on std_err, and raise InternalError *)
  79.  
  80.     val shutdown : (unit -> unit) ref
  81.     (* the termination function *)
  82.  
  83.     val load : unit -> int
  84.     (* return the number of threads on the ready queues *)
  85.  
  86.     val go : time option -> unit
  87.     (* mark the beginning of CML execution and start the timer *)
  88.  
  89.     val stop : unit -> unit
  90.     (* turn the timer off, and mark the end of CML execution *)
  91.  
  92.     val isRunning : unit -> bool
  93.     (* returns true if CML is running *)
  94.  
  95.   end; (* CML_BASE *)
  96.